/**
 * ClassName MyDate
 * Description TODO
 * Author Yanyan
 * Date 2025/11/7 19:46
 * Version 1.0
 */
public class MyDate {

    //成员变量具有默认初始值
    public int year;
    public int month;
    public int day;

//    public boolean flag;

//    public String str;

    public MyDate(){
        //通过this可以调用别的构造方法，但必须在第一行
        this(1900,1,1);
        System.out.println("不带参数的构造方法");
    }

    public MyDate(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("带参数的构造方法");
    }

    //alt+insert 生成构造方法

//    public MyDate(int year) {
//        this.year = year;
//    }


//    public MyDate(int month, int day) {
//        this.month = month;
//        this.day = day;
//    }

    public void setDate(int y, int m, int d) {
        this.year = y;
        this.month = m;
        this.day = d;
    }

//    //系统隐藏的变量this，数据类型是类名。效果一样
//    public void setDate(MyDate this, int year, int month, int day) {
//        this.year = year;
//        this.month = m;
////        this.day = d;
//    }

    public void printDate(){
        System.out.println("year:" + this.year
        + " month: " + this.month + " day: " + day);

        //this.还可以调用成员方法
        this.test();
    }

    public void test() {
        System.out.println("test");
    }

//alt + insert 生成打印toString
    @Override
    public String toString() {
        return "MyDate{" +
                "year=" + year +
                ", month=" + month +
                ", day=" + day +
                '}';
    }
}
